<template>
    <view class="content">
        <view class="box">
			<view>姓名</view>
			<input type="text" v-model="name" maxlength="16" placeholder="请输入姓名" class="inp">
		</view>
		<view class="btn" @click="doSubimt">提交</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                name: '',
            };
        },
        onLoad(option) {
            this.name = option.name
        },
        methods: {
            doSubimt() {
				if (!this.name) {
					this.$toast('姓名不能为空')
					return
				}
				
				this.$ajax('editInfo', {
				    userToken: this.$getSync('userToken'),
					nickname: this.name,
				}).then(ret => {
					if (ret.status == 0) {
				        this.$toast('提交成功')
						uni.$emit('EDITINFO')
						setTimeout(() => {
							this.$backT()
						},500)
					} else {
						this.$toast(ret.message);
					}
				});
			},
        }
    };
</script>

<style lang="scss">
    page{
        background-color: #f5f5f5;
    }
	.content{
		padding: 20rpx;
	}
	.box{
		padding: 35rpx 20rpx;
		background-color: #fff;
		border-radius: 20rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 30rpx;
	}
	.inp{
		flex: 1;
		text-align: right;
		padding-left: 15rpx;
	}
	.btn{
		font-size: 30rpx;
		color: #fff;
		text-align: center;
		padding: 25rpx;
		margin: 40rpx 0;
		background: #01b8bd;
		border-radius: 50rpx;
	}

</style>
